<script setup>
import useMainStore from '@/stores/modules/main'
import { storeToRefs } from 'pinia'
import { formatDate } from '@/utils/formatdate'
import { ref, computed } from 'vue'
const searchValue = ref()

const mainStore = useMainStore()
const { startDateM, endDateM } = storeToRefs(mainStore)

const startDate = computed(() => {
  return formatDate(startDateM.value, 'MM.DD')
})

const endDate = computed(() => {
  return formatDate(endDateM.value, 'MM.DD')
})
</script>

<template>
  <div class="search-box">
    <van-search
      v-model="searchValue"
      left-icon=""
      right-icon="search"
      placeholder="关键字/位置/民宿"
    >
      <template #left>
        <div class="select-time">
          <div class="start">
            <div class="name">住</div>
            <div class="date">{{ startDate }}</div>
          </div>
          <div class="end">
            <div class="name">离</div>
            <div class="date">{{ endDate }}</div>
          </div>
        </div>
      </template>
    </van-search>
  </div>
</template>

<style lang="less" scoped>
.search-box {
  .van-search {
    padding: 0;
  }

  .van-search__content {
    border-radius: 0 5px 5px 0;
  }
  --van-search-input-height: 45px;
  .select-time {
    border-right: 1px solid #fff;
    padding-left: 8px;
    border-radius: 5px 0px 0px 5px;
    height: 45px;
    background-color: #f7f8fa;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #999;
    .start {
      display: flex;
    }
    .end {
      display: flex;
    }
    .date {
      margin-left: 5px;
      margin-right: 8px;
      color: #333;
    }
  }
}
</style>
